package org.blogsomy.model.dao;

import java.util.List;

import org.blogsomy.model.entities.Comment;
import org.blogsomy.model.entities.Post;
import org.blogsomy.model.entities.User;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public class DaoFacade {

	private PostDao postDao;
	
	private UserDao userDao;
	
	private CommentDao commentDao;

	public PostDao getPostDao() {
		return postDao;
	}

	public void setPostDao(PostDao postDao) {
		this.postDao = postDao;
	}

	@Transactional(readOnly = false)
	public void addPost(Post e) {
		postDao.save(e);
	}
	
	public List<Post> getPosts() {
		return postDao.getAll();
	}
	
	public UserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	@Transactional(readOnly = false)
	public void addUser(User e) {
		userDao.save(e);
	}
	
	public List<User> getUsers() {
		return userDao.getAll();
	}
	
	public CommentDao getCommentDao() {
		return commentDao;
	}

	public void setCommentDao(CommentDao commentDao) {
		this.commentDao = commentDao;
	}

	@Transactional(readOnly = false)
	public void addComment(Comment e) {
		commentDao.save(e);
	}
	
	public List<Comment> getComments() {
		return commentDao.getAll();
	}
}

